#include"server.hpp"
#include"protocol.hpp"
#include"netcal.hpp"



int main(int  argc,char** argv)
{
    if(argc != 2)
    {
        std::cout << "Usage:" << argv[0] << " serverport" << std::endl;
        std::exit(static_cast<int>(ExitCode::USAGE_ERR));
    }
    NetCal netcal;
    Protocol protocol([&netcal](Request request)->Response
    {
        return  netcal.Cal(request);
    });
    TcpServer tcpserver(std::stoi(argv[1]),std::bind(&Protocol::GetRequest,&protocol,std::placeholders::_1,std::placeholders::_2));
    tcpserver.Start(); 
     
    return 0;
}